import Vue from 'vue'
import App from './App.vue'
import router from './router'
import LayoutBox from './components/LayoutBox.vue'
import TreeTable from 'vue-table-with-tree-grid'
import './plugins/element.js'
// 导入全局样式表
import './assets/css/global.css'
// 导入字体图标
import './assets/fonts/iconfont.css'

// import axios from 'axios'
import Axios from 'axios'
// 配置请求的根路径
Axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'
Axios.interceptors.request.use(config => {
    // console.log(config);
    // 为请求对象，添加token验证的Authorization字段
    config.headers.Authorization = window.sessionStorage.getItem('token')
        // 在最后必须return config
    return config
})

// 把axios引入到vue中，axios的请求拦截要写在挂载之前
Vue.prototype.$http = Axios // http是自己定义的名字，把包挂载到vue上
Vue.config.productionTip = false

// 添加全局组件
Vue.component('layout-box', LayoutBox)
Vue.component('tree-table', TreeTable)

new Vue({
    router,
    render: h => h(App)
}).$mount('#app')